var $=KISSY.all;
var lvT= ["瞎子", "色盲", "色郎", "色狼", "色鬼", "色魔", "超级色魔", "变态色魔", "孤独求色"];
var lvMap= [2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9];
var lvFinal=2;
function start(lev){
	$(".box").removeClass("lv"+(lvMap[lev]-1));
	$(".box").addClass("lv"+lvMap[lev]);
	var html="<span>";
	var bxs = lvMap[lev]*lvMap[lev];
	var xpint = rnd(0, bxs-1)
	for(var i=0;i<bxs;i++){
		 if(i==xpint){
			html +="<i class=\"p\"></i>";
		 }else{
			html += "<i></i>";
		 }
	}
	html += "</span>";
	$(html).appendTo(".box");
	var xran = 0;
	if(lvMap[lev]<5){
		 xran = 50;
	}else{
		 xran = 10;
	}
	var color = [rnd(0,255),rnd(0,255),rnd(0,255)];
	var ccode = "rgb("+color[0]+","+color[1]+","+color[2]+")";
	var xcode = "rgb("+(color[0]+xran)+","+(color[1]+xran)+","+(color[2]+xran)+")";
	$("i").css("background-color",ccode);
	$(".p").css("background-color",xcode);

	$(".p").on("click",function(){
		$(".box").empty();
		if(lev<31){
			start(lev+1);
		}else{
			start(lev);
		}
		lvFinal=lvMap[lev];
	});
}
start(0);
function rnd(min, max)
{
	return parseInt((Math.random()*999)%(max-min+1))+min;
}